package cn.com.czpb.client.module.news.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 猪猪侠 on 2017/8/9.
 */

public class SearchFragmentPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> listFragments;
    private String titles[] = {"新闻","达人号"};

    public SearchFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
        this.listFragments=new ArrayList<>();

    }
    public void setFragments(List<Fragment> fragments) {
        this.listFragments = fragments;
        notifyDataSetChanged();
    }
    @Override
    public Fragment getItem(int position) {
        return listFragments.get(position);
    }

    @Override
    public int getCount() {
        return listFragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
